<?php

namespace app\model\setting;

use app\model\BaseModel;

class SystemMenus extends BaseModel
{

    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 模型名称
     * @var string
     */
    protected $table = 'free_auth_rule';

    // 设置字段信息
    protected $type = [
        'hidden' => 'boolean',
        'status' => 'boolean',
        'breadcrumb' => 'boolean',
        'affix' => 'boolean',
        'noKeepAlive' => 'boolean',
    ];


    public function getMenuAttr($value)
    {
        $status = [1 => '菜单', 0 => '按钮'];
        return $status[$value];
    }

    public function searchTitleAttr($query, $value, $data)
    {
        $query->where('title', 'like', '%' . $value . '%');
        if (isset($data['sort'])) {
            $query->order($data['sort']);
        }

    }

    public function searchPidAttr($query, $value, $data){
        $query -> where('pid',$value);
    }

    public function searchMenuAttr($query, $value, $data){
        $query -> where('menu',$value);
    }

}